home *** CD-ROM | disk | FTP | other *** search
- global gPlay, gPause, gURLScore, gURLEmail, gURLPing, gSoundOn, GAME_ID, CLIENT_ID, ground, key1, gCheater, isMac, isShockwave, gCookiePath, gGameCookieExists, gCheckLegalCookie, gKewlboxFolder, gStartFrame, gOnline, gMessageBox, gMacSound, gStopURL, gDelayButton, VERSION_NUM, gClientURLs, gBannerList, gNewBanner, gScreenLarge, gDrawStage, gRectStage, gChartLoc, gChart, gGoodNetBanner, gGameStarted, gGameTimerObj, gGameSeconds, gClickOnOnce, gNetID, gCheckPing, gEmailNames, gErrorChar, gDecoyScore, gEncryptScore, NUM_ENCRYPT, ENCRYPT_DENOM, ENCRYPT_PATTERN, gDecoyLives, gEncryptLives, gpTicks
-
- on stopMovie
- if gMacSound <> VOID then
- set the soundLevel to gMacSound
- end if
- end
-
- on startMovie
- clearGlobals()
- end
-
- on startMoviePastLoader
- initScore()
- initGlobals()
- goInitFrameOne()
- resetEverything()
- initStreaming()
- gMessageBox = new(script("p_MessageBox"), 80, 81, 82)
- sound(8).volume = 255
- member("t_Score1").text = "0"
- member("t_Score2").text = "0"
- gStopURL = 0
- end
-
- on initGlobals
- GAME_ID = 66
- CLIENT_ID = 14
- MAJOR_REV = 1
- MINOR_REV = 0
- VERSION_NUM = 1
- gDelayButton = -1
- case VERSION_NUM of
- 1:
- versionLetter = "a"
- 2:
- versionLetter = "b"
- 3:
- versionLetter = "c"
- 4:
- versionLetter = "d"
- 5:
- versionLetter = "e"
- 6:
- versionLetter = "f"
- 7:
- versionLetter = "g"
- otherwise:
- versionLetter = EMPTY
- end case
- theStr = "v" & MAJOR_REV & "." & MINOR_REV & versionLetter
- member("t_VersionNumber").text = theStr
- if VERSION_NUM > 7 then
- alert("Do not have a URL for this version" && theStr)
- end if
- gClientURLs = ["http://www.att.com/tracking/game1", "http://www.att.com/tracking/game2", "http://www.att.com/tracking/game3", "http://www.att.com/tracking/game4", "http://www.att.com/tracking/game5", "http://www.att.com/tracking/game6", "http://www.att.com/tracking/game7"]
- gURLScore = "http://www.kewlbox.com/scores/direct.cfm?"
- gURLEmail = "http://www.kewlbox.com/email/direct.cfm?"
- gURLPing = "http://www.kewlbox.com/ping/ping.cfm?"
- setConditionalMode()
- gPlay = 0
- gPause = 0
- gGameStarted = 0
- gGameSeconds = 0
- gSoundOn = 0
- ground = 1
- end
-
- on setConditionalMode
- if the runMode contains "Plugin" then
- isShockwave = 1
- else
- isShockwave = 0
- end if
- if (the environment).platform contains "Macintosh,PowerPC" then
- isMac = 1
- gMacSound = the soundLevel
- else
- isMac = 0
- gMacSound = 7
- end if
- if (the environment).internetConnected = #online then
- gOnline = 1
- else
- gOnline = 0
- end if
- gStartFrame = "Main"
- end
-
- on doShockwaveLoadGraphic
- return isShockwave
- end
-
- on getDateIndex
- theMonth = (the systemDate).month
- theDay = (the systemDate).day
- theYear = (the systemDate).year
- dateIndex = (theYear * 10000) + (theMonth * 100) + theDay
- return dateIndex
- end
-
- on checkDate
- dateIndex = getDateIndex()
- expIndex = 20020607
- expDate = "6/07/2002"
- if dateIndex >= expIndex then
- alert("This game has expired.")
- quit()
- else
- alert("This game expires on" && expDate)
- end if
- end
-
- on getYear
- tempStr = the date
- n = length(tempStr)
- theYear = -1
- firstPos = -1
- lastPos = -1
- repeat with i = 1 to n
- c = chars(tempStr, i, i)
- if (c < "0") or (c > "9") then
- lastPos = i
- if firstPos = -1 then
- firstPos = i
- end if
- end if
- end repeat
- if lastPos >= 0 then
- try1 = value(chars(tempStr, lastPos + 1, n))
- if (try1 >= 1980) and (try1 < 2200) then
- theYear = try1
- end if
- end if
- if (theYear < 0) and (firstPos > 0) then
- try1 = value(chars(tempStr, 1, firstPos - 1))
- if (try1 >= 1980) and (try1 < 2200) then
- theYear = try1
- end if
- end if
- if theYear < 0 then
- theYear = value(chars(tempStr, n - 1, n))
- end if
- if theYear < 80 then
- theYear = theYear + 2000
- else
- if theYear < 100 then
- theYear = theYear + 1900
- end if
- end if
- return theYear
- end
-
- on resetEverything
- member("t_Level").text = "1"
- member("t_Rows").text = "0"
- member("f_reciveText").text = EMPTY
- gBannerList = [:]
- gScreenLarge = 0
- gDrawStage = (the stage).drawRect
- gRectStage = (the stage).rect
- gNewBanner = 0
- gGoodNetBanner = 0
- gChart = "on"
- gChartLoc = [:]
- l = the number of lines in the text of member "f_ChartLoc"
- repeat with i = 1 to l
- addProp(gChartLoc, i, member("f_ChartLoc").line[i])
- end repeat
- end
-
- on checkGameTime
- if gGameStarted = 0 then
- gGameStarted = 1
- gGameTimerObj = new(script("p_timer"))
- resetTimer(gGameTimerObj)
- runTimer(gGameTimerObj)
- end if
- gGameSeconds = float(reportTimer(gGameTimerObj))
- end
-
- on ping
- gNetID = bdGetNetText(gURLPing & GAME_ID & "&clientId=" & CLIENT_ID)
- gCheckPing = 1
- end
-
- on ping2
- gNetID = bdGetNetText(gURLPing & GAME_ID & "&clientId=" & CLIENT_ID & "&time=" & integer(gGameSeconds))
- end
-
- on submitEmail
- gEmailNames = EMPTY
- gErrorChar = [1: "\", 2: "\", 3: "#", 4: "?", 5: "%", 6: "\\", 7: "/"]
- repeat with i = 1 to 5
- box = "f_EmailBox" & i
- if member(box).text = EMPTY then
- next repeat
- next repeat
- end if
- put "&" & "email" & i & "=" & member(box).text after gEmailNames
- end repeat
- repeat with y = 1 to 2
- z = getProp(gErrorChar, y)
- repeat with x = 1 to 200
- if gEmailNames.char[x] = "$" then
- delete gEmailNames.char[x]
- end if
- end repeat
- end repeat
- put gURLEmail & "&gameId=" & GAME_ID & "&clientId=" & CLIENT_ID & gEmailNames
- bdWebCommunicate(gURLEmail & "&gameId=" & GAME_ID & "&clientId=" & CLIENT_ID & gEmailNames, 1)
- end
-
- on setScoreParams
- tempScore = getScore()
- ScoreMod = (tempScore + (3 * GAME_ID)) mod 13579
- key2 = (4 * (ScoreMod * ScoreMod)) + (23 * ScoreMod) + (key1 * 54)
- key2 = key2 mod 1000000
- t = "&score=" & tempScore
- t = t & "&key1=" & key1
- t = t & "&key2=" & key2
- return t
- end
-
- on postScore
- if gCheater = 0 then
- temp = gURLScore & "gameID=" & GAME_ID & "&clientID=" & CLIENT_ID & setScoreParams()
- bdWebCommunicate(temp, 1)
- end if
- end
-
- on initScore
- gEncryptScore = []
- gCheater = 0
- NUM_ENCRYPT = 6
- ENCRYPT_DENOM = 117
- ENCRYPT_PATTERN = 214
- setScore(0)
- end
-
- on rotateByteRight x, n
- n = n mod 8
- x2 = x
- x3 = x
- if n > 0 then
- repeat with i = 1 to n
- x2 = integer(x2 / 2)
- x3 = x3 * 2
- end repeat
- n = 8 - n
- repeat with i = 1 to n
- x3 = x3 * 2 mod 256
- end repeat
- x = x2 + x3
- end if
- return x
- end
-
- on exclusiveOr x1, x2
- sum = 0
- p2 = 1
- repeat with i = 1 to 8
- m1 = x1 mod 2
- m2 = x2 mod 2
- if (m1 + m2) = 1 then
- sum = sum + p2
- end if
- x1 = integer(x1 / 2)
- x2 = integer(x2 / 2)
- p2 = 2 * p2
- end repeat
- return sum
- end
-
- on setScore n
- gDecoyScore = n
- last = 0
- repeat with i = 1 to NUM_ENCRYPT
- gEncryptScore[i] = exclusiveOr(n mod ENCRYPT_DENOM, rotateByteRight(ENCRYPT_PATTERN, i - 1))
- last = last + rotateByteRight(gEncryptScore[i], i - 1)
- n = integer(n / ENCRYPT_DENOM)
- end repeat
- gEncryptScore[NUM_ENCRYPT + 1] = last
- put gDecoyScore into member "t_TotalScore"
- end
-
- on setLives n
- gDecoyLives = n
- last = 0
- repeat with i = 1 to NUM_ENCRYPT
- gEncryptLives[i] = exclusiveOr(n mod ENCRYPT_DENOM, rotateByteRight(ENCRYPT_PATTERN, i - 1))
- last = last + rotateByteRight(gEncryptLives[i], i - 1)
- n = integer(n / ENCRYPT_DENOM)
- end repeat
- gEncryptLives[NUM_ENCRYPT + 1] = last
- put gDecoyLives into member "t_Lives"
- end
-
- on getScore
- realScore = 0
- last = 0
- repeat with i = NUM_ENCRYPT down to 1
- realScore = (realScore * ENCRYPT_DENOM) + exclusiveOr(gEncryptScore[i], rotateByteRight(ENCRYPT_PATTERN, i - 1))
- last = last + rotateByteRight(gEncryptScore[i], i - 1)
- end repeat
- if last <> gEncryptScore[NUM_ENCRYPT + 1] then
- realScore = 0
- gCheater = 1
- end if
- return realScore
- end
-
- on getLives
- realLives = 0
- last = 0
- repeat with i = NUM_ENCRYPT down to 1
- realLives = (realLives * ENCRYPT_DENOM) + exclusiveOr(gEncryptLives[i], rotateByteRight(ENCRYPT_PATTERN, i - 1))
- last = last + rotateByteRight(gEncryptLives[i], i - 1)
- end repeat
- if last <> gEncryptLives[NUM_ENCRYPT + 1] then
- realLives = 0
- gCheater = 1
- end if
- return realLives
- end
-
- on findSoundChannel
- repeat with i = 1 to 5
- if not soundBusy(i) then
- whichChannel = i
- exit repeat
- end if
- end repeat
- if not voidp(whichChannel) then
- return whichChannel
- else
- return 1
- end if
- end
-
- on saveText text, fileName, dialogBox, appendFile
- fileObj = new(xtra("FileIO"))
- if dialogBox = 1 then
- if the platform contains "Mac" then
- setFilterMask(fileObj, "TEXT")
- else
- setFilterMask(fileObj, "Text Files,*.txt, AllFiles,*.*")
- end if
- fileName = displaySave(fileObj, EMPTY, EMPTY)
- if fileName = EMPTY then
- return 0
- end if
- end if
- if appendFile = 0 then
- openFile(fileObj, fileName, 2)
- delete(fileObj)
- end if
- createFile(fileObj, fileName)
- openFile(fileObj, fileName, 0)
- if status(fileObj) <> 0 then
- err = error(fileObj, status(fileObj))
- alert("Error: " && err)
- return 0
- end if
- setPosition(fileObj, getLength(fileObj))
- writeString(fileObj, text)
- if the platform contains "Mac" then
- setFinderInfo(fileObj, "TEXT ttxt")
- end if
- closeFile(fileObj)
- return 1
- end
-
- on openAndReadText fileName, dialogBox
- fileObj = new(xtra("FileIO"))
- if dialogBox = 1 then
- if the platform contains "Mac" then
- setFilterMask(fileObj, "TEXT")
- else
- setFilterMask(fileObj, "Text Files,*.txt,All Files,*.*")
- end if
- fileName = displayOpen(fileObj)
- if fileName = EMPTY then
- return EMPTY
- end if
- end if
- openFile(fileObj, fileName, 1)
- if status(fileObj) <> 0 then
- err = error(fileObj, status(fileObj))
- alert("Error:" && err)
- return EMPTY
- end if
- text = readFile(fileObj)
- closeFile(fileObj)
- return text
- end
-
- on checkPingResult
- if gCheckPing = 1 then
- doExit = 0
- if gpTicks <= 400 then
- if netError(gNetID) = "OK" then
- put netError(gNetID) & "Yes"
- put netTextresult()
- gCheckPing = 0
- if gNewBanner = 0 then
- getNewBanner()
- gNewBanner = 1
- end if
- doExit = 1
- else
- if netError(gNetID) = 4146 then
- gNewBanner = 0
- put netError(gNetID) & "No Connection"
- gCheckPing = 0
- doExit = 1
- else
- gpTicks = gpTicks + 1
- put netError(gNetID) & "Waiting"
- end if
- end if
- else
- put "Nothing"
- gNewBanner = 0
- gCheckPing = 0
- doExit = 1
- end if
- else
- doExit = 1
- end if
- return doExit
- end
-
- on bdWebCommunicate urlString, newBrowser
- if newBrowser = VOID then
- newBrowser = 0
- end if
- put "WebComm:" && urlString && newBrowser
- isSw = the runMode contains "Plugin"
- if isSw = 1 then
- if newBrowser = 1 then
- gotoNetPage(urlString, "_new")
- else
- gotoNetPage(urlString)
- end if
- else
- gsOpenURL(urlString)
- end if
- end
-
- on bdGetNetText urlString
- put "getNetText:" && urlString
- return getNetText(urlString)
- end
-